home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3042 < prev    next >
Encoding:
Text File  |  1996-08-06  |  985 b   |  53 lines

  1. Path: mars.efn.org!rose_ip187
  2. From: peterf@gears.efn.org
  3. Newsgroups: comp.lang.c++
  4. Subject: re: C++ display Ascii file
  5. Date: Sun, 21 Jan 96 18:49:47 GMT
  6. Organization: Oregon Public Networking
  7. Message-ID: <4duc2n$jlr@mars.efn.org>
  8. NNTP-Posting-Host: rose_ip187.efn.org
  9. X-Newsreader: News Xpress Version 1.0 Beta #3
  10.  
  11. Dear Shane,
  12.  
  13. Here is some help, I will rewrite your program using diff. method....
  14.  
  15. #include <fstream.h>
  16. #include <conio.h>
  17. #include <process.h>
  18.  
  19. void foerror(int);
  20.  
  21. void main(int argc, char* argv[])
  22.  {
  23.   char chr;
  24.  
  25.    if(argc!=2)
  26.     { foerror(argc); }
  27.  
  28.   ifstream infile(argv[1]);
  29.  
  30.    if(!infile)
  31.     {
  32.      cerr << "\nUnable to read " << argv[1] << endl;
  33.      exit(-1);
  34.     }
  35.  
  36.    while(infile)
  37.     {
  38.      infile.get(chr);
  39.      cout << chr;
  40.     }
  41.  }
  42.  
  43. void foerror(int argc)
  44.  {
  45.   if(argc!=2)
  46.    {
  47.     cerr << "\nExample 1: Drive:\\Your sub-dir\\Ftype Filename" << endl;
  48.     cerr << "or";
  49.     cerr << "\nExample 2: Drive:\\Ftype Filename" << endl;
  50.     exit(-1);
  51.    }
  52.  }
  53.